package com.anxin.controller;

import com.anxin.security.jwt.JwtTokenProvider;
import org.springframework.beans.factory.annotation.Autowired;

public class BaseController {
    @Autowired
    protected JwtTokenProvider jwtTokenProvider;


    /**
     * 获取当前登录用户ID,判断是否登录
     */
//    protected String getLoginUserId(HttpServletRequest request) {
//        String auth = request.getHeader("Authorization");
//        if (auth == null || !auth.startsWith("Bearer ")) {
//            throw new RuntimeException("未登录");
//        }
//        String token = auth.substring(7);
//        try {
//            return jwtTokenProvider.getUsernameFromJWT(token);
//        } catch (Exception e) {
//            throw new RuntimeException("token无效");
//        }
//    }


}
